package com.net.xpay.web.controller.open;

import com.google.common.base.Strings;
import com.net.common.util.SerializationUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * 2020/9/17 14:46

 * 测试用的
 */
@RestController
@Slf4j
@RequestMapping("/open/test")
@Api(tags = "第三方开放调用/测试用的", description = "第三方开放调用 测试用的 net")
public class OpenTestApiController {

    @ApiOperation(value = "测试推送")
    @PostMapping("/notify")
    public String testNotify(HttpServletRequest request) {
        log.info("testNotify request={}", SerializationUtil.obj2String(request.getParameterMap()));

        Map<String, String> map = new HashMap<>();

        request.getParameterMap().forEach((k, v) -> {
            if (!Strings.isNullOrEmpty(v[0])) {
                map.put(k, v[0]);
            }
        });


        log.info("testNotify params={}", SerializationUtil.obj2String(map));

        return "ok";
    }


}
